<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    request.setAttribute("path", path);
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>标题</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!-- 引入 echarts.js -->
    <script src="${pageContext.request.contextPath}/echarts/echarts.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.js"></script>

</head>
<body>
<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="main" style="width: 1200px;height:500px;display:inline-block"></div>
<%--<SCRIPT type="text/javascript">
    var chartDom = document.getElementById('main');
    var myChart = echarts.init(chartDom);
    var option;

    setTimeout(function () {

        option = {
            title: {
                text: '2012-2020年度出版社销售排行(单位：本)'
            },
            legend: {},
            tooltip: {
                trigger: 'axis',
                showContent: false
            },
            dataset: {
                source: [
                    ['product', '2012', '2013', '2014', '2015', '2016', '2017', '2018', '2019', '2020'],
                    ['中华书局', 18200, 16852, 16887, 11785, 13682, 17720,14536,12410,22506,20623,12760,11849],
                    ['人民出版社', 11511, 12514, 15723, 20852, 12736, 17687,20030,10684,13610,12569,11985,15450],
                    ['aaa出版社', 12863, 10622, 11695, 20694, 11452, 12820,17630,16682,18540,10369,11570,13420],
                    ['电子出版社', 11052, 20371, 11412, 12818, 15339, 12491,18420,20368,17750,12663,11520,10606],
                    ['311出版社', 15452, 12371, 10512, 17618, 20739, 11491,13420,18568,19750,12763,15526,13806]
                ]
            },
            xAxis: {type: 'category'},
            yAxis: {gridIndex: 0},
            grid: {top: '55%'},
            series: [
                {type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: {focus: 'series'}},
                {type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: {focus: 'series'}},
                {type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: {focus: 'series'}},
                {type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: {focus: 'series'}},
                {type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: {focus: 'series'}},
                {
                    type: 'pie',
                    id: 'pie',
                    radius: '30%',
                    center: ['50%', '25%'],
                    emphasis: {focus: 'data'},
                    label: {
                        formatter: '{b}: {@2020} ({d}%)'
                    },
                    encode: {
                        itemName: 'product',
                        value: '2020',
                        tooltip: '2020'
                    }
                }
            ]
        };

        myChart.on('updateAxisPointer', function (event) {
            var xAxisInfo = event.axesInfo[0];
            if (xAxisInfo) {
                var dimension = xAxisInfo.value + 1;
                myChart.setOption({
                    series: {
                        id: 'pie',
                        label: {
                            formatter: '{b}: {@[' + dimension + ']} ({d}%)'
                        },
                        encode: {
                            value: dimension,
                            tooltip: dimension
                        }
                    }
                });
            }
        });

        myChart.setOption(option);

    });

    option && myChart.setOption(option);


</SCRIPT>--%>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    /*var chartDom = document.getElementById('main');
    var myChart = echarts.init(chartDom);
    var option;*/
    var myChart = echarts.init(document.getElementById('main'));

    $.ajax({
        type:'post',
        ///store/selectCountGroup
        url:'${pageContext.request.contextPath}/store/selectPublisher',
        dataType:'json',
        success:function (data) {
            //alert(data)
            myChart.hideLoading();//加载数据
            myChart.setOption({//渲染
                title: {
                    text: '2020年出版社销售排行(单位：元)'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    top: '5%',
                    left: 'center'
                },
                series: [
                    {
                        name: '销售说明',
                        type: 'pie',
                        radius: ['40%', '70%'],
                        avoidLabelOverlap: false,
                        itemStyle: {
                            borderRadius: 10,
                            borderColor: '#fff',
                            borderWidth: 2
                        },
                        label: {
                            show: false,
                            position: 'center'
                        },
                        emphasis: {
                            label: {
                                show: true,
                                fontSize: '40',
                                fontWeight: 'bold'
                            }
                        },
                        labelLine: {
                            show: false
                        },
                        data:data
                    }
                ]
            });
        }
    });
</script>
</body>
</html>
